//
//  AutomaticLayoutTableViewCell.swift
//  SwiftTest
//


import UIKit

class AutomaticLayoutTableViewCell: UITableViewCell {



    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
    }
    
    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)
        
        // Configure the view for the selected state
    }
    //实例化方法
    required init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
    }
    
    class func tableViewBack(tableV:UITableView) -> AutomaticLayoutTableViewCell {
        let cellid = "AutomaticLayoutTableViewCell"
        var cell:AutomaticLayoutTableViewCell!
        
        if let cellBeforWarrp = tableV.dequeueReusableCell(withIdentifier: cellid) as? AutomaticLayoutTableViewCell{
            cell = cellBeforWarrp
        }else{
            cell = AutomaticLayoutTableViewCell.init(style: UITableViewCell.CellStyle.default, reuseIdentifier: cellid)
        }
        cell.selectionStyle = UITableViewCell.SelectionStyle.none
//        cell.backgroundColor = UIColor.brown
        return cell
    }
    
    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        self.creatUI()
    }
    func creatUI() {
        let lab = UILabel.init()
        lab.text = "动态布局tablewCell"
        lab.textColor = UIColor.black
        self.contentView.addSubview(lab)
        lab.snp.makeConstraints { (make) in
            make.left.top.equalTo(10)
            make.height.equalTo(20)
        }
        let but = UIButton.init()
        but.backgroundColor = UIColor.red
        self.contentView.addSubview(but)
        but.snp.makeConstraints { (make) in
            make.width.equalTo(100);
            make.left.equalTo(10);
            make.top.equalTo(lab.snp_bottom).offset(10)
            make.bottom.equalTo(self.contentView).offset(-10)
            make.height.equalTo(100).priority(900)
        }
        
        
    }
}
